package com.softserveinc.autorent.manager;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import com.softserveinc.autorent.model.Order;

@Stateless
public class OrderEJB extends AbstractEJB<Order> {

	@PersistenceContext(unitName = "jpa")
	private EntityManager em;

	public OrderEJB() {
		super(Order.class);
	}	

	@Override
	public EntityManager getEntityManager() {
		return em;
	}

	@Override
	public void setEntityManager(EntityManager em) {
		this.em = em;
	}

	@Override
	public List<Order> findAll() {
        TypedQuery<Order> query = em.createNamedQuery("findAllOrders", Order.class);
        return query.getResultList();
	}
}
